<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
	<xsl:template name="get-control-name">
		<xsl:choose>
			<xsl:when test="type='label'">lbl</xsl:when>
			<xsl:when test="type='text'">txt</xsl:when>
			<xsl:when test="type='date'">dte</xsl:when>
			<xsl:when test="type='check'">chk</xsl:when>
			<xsl:when test="type='combo'">cbe</xsl:when>
			<xsl:when test="type='lookup'">bte</xsl:when>
			<xsl:when test="type='combolookup'">cbe</xsl:when>
		</xsl:choose>
		<xsl:value-of select="name"/>
	</xsl:template>
	<xsl:template name="get-bind-type">
		<xsl:choose>
			<xsl:when test="type='text'">Bind</xsl:when>
			<xsl:when test="type='date'">Bind</xsl:when>
			<xsl:when test="type='check'">Bind</xsl:when>
			<xsl:when test="type='combo'">BindCustomType</xsl:when>
			<xsl:when test="type='lookup'">BindCustomType</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="get-bind">
		<xsl:choose>
			<xsl:when test="type='text'"><xsl:choose>
				<xsl:when test="display_format=''">BindableTextEdit(<xsl:call-template name="get-control-name"/>)</xsl:when>
				<xsl:otherwise>BindableTextEdit(<xsl:call-template name="get-control-name"/>, new DisplayConverter("<xsl:value-of select="display_format"/>"))</xsl:otherwise>
			</xsl:choose>
			</xsl:when>
			<xsl:when test="type='date'">BindableDateEdit(<xsl:call-template name="get-control-name"/>, <xsl:call-template name="allow-null"/>)</xsl:when>
			<xsl:when test="type='check'">BindableCheckEdit(<xsl:call-template name="get-control-name"/>)</xsl:when>
			<xsl:when test="type='combo'">BindableComboBoxEdit(<xsl:call-template name="get-control-name"/>, <xsl:value-of select="fk_class_name"/>.GetAll(), <xsl:call-template name="allow-null"/>)</xsl:when>
			<xsl:when test="type='lookup'">BindableButtonEdit&lt;<xsl:value-of select="fk_class_name"/>&gt;(<xsl:call-template name="get-control-name"/>, LookupHelper.TryGet<xsl:value-of select="fk_class_name"/>, <xsl:call-template name="allow-null"/>)</xsl:when>
		</xsl:choose>
	</xsl:template>
	<xsl:template name="allow-null">
	  <xsl:choose><xsl:when test="allow_null='true'">true</xsl:when><xsl:otherwise>false</xsl:otherwise></xsl:choose>
	</xsl:template>
<xsl:template match="/editform">using System;
using System.Linq;
using System.Xml.Linq;
using System.Windows.Forms;
using CSW.Framework.UI.Binding;
using CSW.Framework.UI.DevEx.Binding;
using CSW.Framework.UI.DevEx.Forms;
using <xsl:value-of select="root_namespace"/>.Business.Tables;
using <xsl:value-of select="root_namespace"/>.Forms.Lookup;
using PropertyName = <xsl:value-of select="root_namespace"/>.Business.Tables.<xsl:value-of select="table_class_name"/>.PropertyNames;

namespace <xsl:value-of select="root_namespace"/>.Forms.Edit
{
    internal partial class <xsl:value-of select="table_class_name"/>EditForm : BaseEditRecordForm
    {
        private readonly <xsl:value-of select="table_class_name"/> m_<xsl:value-of select="table_class_name"/>;
        private readonly EditFormBinder m_Binder;

		public <xsl:value-of select="table_class_name"/>EditForm(<xsl:value-of select="table_class_name"/> item)
			: this(item, true)
		{
		}
		
        public <xsl:value-of select="table_class_name"/>EditForm(<xsl:value-of select="table_class_name"/> item, bool isParentRecord)
        {
            InitializeComponent();

            m_<xsl:value-of select="table_class_name"/> = item;

			m_Binder = new EditFormBinder(this, m_<xsl:value-of select="table_class_name"/>, new DXError(dxErrorProvider1), cmdSave, "<xsl:value-of select="table_class_name"/>", isParentRecord, false);
            <xsl:for-each select="control[type!='label']">m_Binder.<xsl:call-template name="get-bind-type"/>(new <xsl:call-template name="get-bind"/>, PropertyName.<xsl:value-of select="property_name" />);
            </xsl:for-each>
            m_Binder.UpdateControls();
        }
    }
}
</xsl:template>
</xsl:stylesheet>